<template>

</template>

<script>
export default {
  name: 'autologin',
  data() {
    return {
    }
  },
  created() {
    let loginForm = {
      username: this.getUrlKey('account'),
      password: this.getUrlKey('pwd')
    }
    this.$store.dispatch('LoginByUsername', loginForm).then((res) => {
      this.$router.push({ path: '/' })
    })
  },
  methods: {
    getUrlKey(name) {
      if (new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href))
        return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(location.href) || [''])[1].replace(/\+/g, '%20')) || null
    }
  }
}
</script>
